/**
 * Created by songt on 15/1/5.
 * Email songt@nbpt.cn
 * Author Songt
 * Version 1.0.0
 */
(function($){
	/*
	 Example:
	 $("body").nbptLoading({
	 text: "数据加载中",
	 show: true
	 });
	 $("body").nbptLoading({
	 text: "数据加载中",
	 show: false
	 });
	 */
	$.fn.nbptLoading = function (options) {
		var defaults = {
			text: '数据加载中',
			show: true,
			opacity:0.7
		};
		// Extend our default options with those provided.
		var opts = $.extend(defaults, options);
		// Our plugin implementation code goes here.

		/*var height = $(document.body).height()+"px";
		 var width = $(document.body).width()+"px";*/

		var loadingDiv = "<div nbloading='loading' style='width: 100%; height: 100%; position: fixed; z-index: 99999999999; top: 0px; left: 0px; overflow: hidden;background: rgba(0, 0, 0,"+opts.opacity+");background: rgb(66,66,66)\\9;'>" +
			"<div style='background: rgba(0,0,0,0.3);padding:10px 5px;width: 180px;height: auto;border-radius: 5px;color: #fff;text-align: center;" +
			"left: 50%;top: 45%;font-size:12px;margin-left: -100px;margin-top:-20px;line-height: 40px;position: fixed;' nbloading='loadingText'><div class='loader loader--audioWave'></div>"+"<i class='icon-spinner2 icon-spin' style='color: #24C5FF'></i> "+opts.text+"</div>" +
			"" +
			"</div>";
		//var cycle;
		var methods = {
			show: function () {
				$("body").append(loadingDiv);
			},
			hide: function () {
				$("[nbloading='loading']").remove();
			}
		};
		if(opts.show){
			methods.show();
		}else if(!opts.show){
			methods.hide();
		}
	}
})(jQuery);